package com.alog.yzd.bookmall.domain.cart;

import com.alog.yzd.bookmall.domain.book.Book;
import com.alog.yzd.bookmall.domain.user.User;

import java.math.BigDecimal;

public class CartItem {
    private String cartItemId;
    private int quantity;
    private Book book;
    private User user;
    private int orderBy;

    public double getSubtotal(){
        return new BigDecimal(book.getCurrPrice() + "").multiply(new BigDecimal(quantity + "")).doubleValue();
    }

    public String getCartItemId() {
        return cartItemId;
    }

    public void setCartItemId(String cartItemId) {
        this.cartItemId = cartItemId;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public int getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(int orderBy) {
        this.orderBy = orderBy;
    }

    @Override
    public String toString() {
        return "CartItem{" +
                "cartItemId='" + cartItemId + '\'' +
                ", quantity=" + quantity +
                ", book=" + book.getBid() +
                ", user=" + user.getUid() +
                ", orderBy=" + orderBy +
                '}';
    }
}
